/*******************************************************************************
  * Copyright (c) 2013 E.W.Clay.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
  *******************************************************************************/ 

#pragma once

#include "surface.h"
#include "colour.h"

namespace Render
{
	struct Rect 
	{
		int16 x, y;
		uint16 w, h;
	};

	void SetRenderTarget(SurfacePtr surface);
	void SetClipRect(const Rect* pRect);

	void Clear(const Colour& rgba);

	// Primitives
	void DrawLine(int x1, int y1, int x2, int y2, const Colour& rgba);
	void DrawRect(int x1, int y1, int x2, int y2, const Colour& rgba);
	void DrawPixel(int x, int y, const Colour& rgba);
	void DrawCircle(int x, int y, int r, const Colour& rgba);
	void FillRect(int x1, int y1, int x2, int y2, const Colour& rgba);
	void FillCircle(int x, int y, int r, const Colour& rgba);
	void DrawHLine(int x1, int y1, int x2, const Colour& rgba);
	void DrawVLine(int x1, int y1, int y2, const Colour& rgba);

	// Blitting
	void BeginDeferredBitmapDrawing();
	void EndDeferredBitmapDrawing();
	void DrawSprite(const SurfacePtr src, int x, int y);
	void Blit(const SurfacePtr src, int x, int y, const Rect& srcRect);
	void Blit(const SurfacePtr src, int x, int y, const Rect& srcRect, const Colour& rgba);
	void RotoZoom(const SurfacePtr src, int x, int y, const Render::Rect& srcRect, int offsetX, int offsetY, float rotation, float zoom);

	// Deferred
	void BeginDeferredPolygonRendering();
	void BeginDeferredLineRendering();
	void BeginDeferredPointRendering();
	void EndDeferredRendering();

	void FillPolygon_Deferred(const float x[], const float y[], const Colour rgba[], int count);
	void FillPolygonCentred_Deferred(const float x[], const float y[], const Colour rgba[], int count);
	void FillRect_Deferred(int x1, int y1, int x2, int y2, const Colour& rgba);
	void DrawLine_Deferred(int x1, int y1, int x2, int y2, const Colour& rgba);
	void DrawRect_Deferred(int x1, int y1, int x2, int y2, const Colour& rgba);
	void DrawPixel_Deferred(int x, int y, const Colour& rgba);
}
